package com.yuyue.springFramework.note02.entity;
/**
 * 通过构造器装配对象
 */
public class AutowireByConstructor {
    ConstructEntity1 constructEntity1;
    ConstructEntity2 constructEntity2;

    //无参构造
    public AutowireByConstructor(){
        System.out.println("无参构造");
    }
    //一个参数构造
    public AutowireByConstructor(ConstructEntity1 constructEntity1){
        this.constructEntity1 = constructEntity1;
        System.out.println("单参构造");
    }
    //两个参数构造
    public AutowireByConstructor(ConstructEntity1 constructEntity1, ConstructEntity2 constructEntity2){
        this.constructEntity1 = constructEntity1;
        this.constructEntity2 = constructEntity2;
        System.out.println("多参构造");
    }

    //set、get和toString方法
    public ConstructEntity1 getConstructEntity1() {
        return constructEntity1;
    }

    public void setConstructEntity1(ConstructEntity1 constructEntity1) {
        this.constructEntity1 = constructEntity1;
    }

    public ConstructEntity2 getConstructEntity2() {
        return constructEntity2;
    }

    public void setConstructEntity2(ConstructEntity2 constructEntity2) {
        this.constructEntity2 = constructEntity2;
    }

    @Override
    public String toString() {
        return "AutowireByConstructor{" +
                "constructEntity1=" + constructEntity1 +
                ", constructEntity2=" + constructEntity2 +
                '}';
    }
}
